#include "widget.h"
#include "ui_widget.h"
#include<QtGui/QApplicationStateChangeEvent>
#include<QTextCodec>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    this->setFixedSize(1000,659);
    this->setWindowTitle("捕捉你心仪的角色");//标题名称
    this->setWindowIcon(QIcon("D:/QT project/fish/sucai/1.png"));//标题上的图标

    QPalette palette;//调色板
    //palette.setColor(QPalette::Background,Qt::blue);
    //this->setPalette(palette);//设置背景颜色

    palette.setBrush(QPalette::Background,QBrush(QPixmap("D:/QT project/fish/sucai/beijin.png")));//设置背景图片
    this->setPalette(palette);

    //标签初始化
    this->label=new QLabel(this);
    label->setPixmap(QPixmap("D:/QT project/fish/sucai/lab1.png"));//标签图片

    //添加按钮
    this->startbtn=new QPushButton(this);
    this->startbtn->setIcon(QIcon("D:/QT project/fish/sucai/annu1.jpg"));//按钮图片
    this->startbtn->setIconSize(QSize(200,80));//按钮大小
    this->startbtn->setFlat(true);
    this->setFocusPolicy(Qt::NoFocus);

    this->helpbtn=new QPushButton(this);
    this->helpbtn->setIcon(QIcon(":/annu2.png"));//按钮图片
    this->helpbtn->setIconSize(QSize(200,80));//按钮大小
    this->helpbtn->setFlat(true);
    this->setFocusPolicy(Qt::NoFocus);

    this->quitbtn=new QPushButton(this);
    this->quitbtn->setIcon(QIcon(":/annu3.png"));//按钮图片
    this->quitbtn->setIconSize(QSize(100,80));//按钮大小
    this->quitbtn->setFlat(true);
    this->setFocusPolicy(Qt::NoFocus);



    //创建一个垂直布局类
    this->vboxlayout=new QVBoxLayout(this);
    this->vboxlayout->addWidget(label);
    this->vboxlayout->addWidget(startbtn);
    this->vboxlayout->addWidget(helpbtn);
    this->vboxlayout->addWidget(quitbtn);
    this->vboxlayout->setAlignment(Qt::AlignCenter);

    w=new gamewidget(this);
    w->hide();
    //信号与槽关联
    this->connect(startbtn,SIGNAL(clicked()),this,SLOT(startbtnclick()));



}

Widget::~Widget()
{
    delete label;
    delete startbtn;
    delete setbtn;
    delete helpbtn;
    delete quitbtn;
    delete w;
    delete ui;
}

void Widget::startbtnclick()
{
    w->show();
}
/*void Widget::quitbtn()
{

}
*/
